<template>
    <div class="pages">
        <van-nav-bar title="账单详情" left-arrow fixed safe-area-inset-top @click-left="onClickLeft"></van-nav-bar>

        <div class="content">
            <div class="content-item">
                <div class="item-title">关联订单号：{{ info.order_num }}</div>
                <div>
                    <!-- <div class="item-flex">
                        <div class="item-name">账单单数</div>
                        <div class="item-num">{{ info.count }}单</div>
                    </div> -->
                    <div class="item-flex">
                        <div class="item-name">账单金额</div>
                        <div class="item-price">¥{{ info.price }}</div>
                    </div>
                    <div class="item-flex">
                                <div class="item-name">下单店铺</div>
                                <div class="item-num">{{ info.user_shop_name }}</div>
                            </div>
                    <div class="item-flex">
                        <div class="item-name">账单时间</div>
                        <div class="item-num">{{ info.dates }}</div>
                    </div>
                    <div class="item-flex">
                        <div class="item-name">对公账户</div>
                        <div class="item-num">{{ money_account.name }}</div>
                    </div>
                    <div class="item-flex">
                        <div class="item-name">对公账号</div>
                        <div class="item-num">{{ money_account.account }}</div>
                    </div>
                    <div class="item-flex">
                        <div class="item-name">开户银行</div>
                        <div class="item-num">{{ money_account.bank_name }}</div>
                    </div>
                    <div v-if="info.pics" class="item-flex flex-start">
                        <div class="item-name">账单单据</div>
                        <img class="item-img" @click="seeImg(info.pics)" :src="info.pics" alt="">
                    </div>
                </div>
            </div>

            <div class="delivery" >
				<div class="delivery-title">
					<div>配送商品</div>
					<!-- <div class="title-right">
                        <span>采购金额&nbsp;</span>
                        <span class="right-price">¥{{ info.base_price }}</span>
                    </div> -->
				</div>
				<div class="delivery-item" v-for="(itemC,indexC) in list" :key="indexC" @click="onDetail(itemC)">
					<img class="item-img" :src="itemC.good_pics"  />
					<div class="item-right">
						<div class="item-flex">
							<div class="item-des">{{ itemC.good_name }}</div>
							<div class="item-price">
								<span class="price-icon">¥</span>
								<span>{{ itemC.base_price_arr.z_price }}</span>
								<span class="price-small">.{{ itemC.base_price_arr.x_price }}</span>
							</div>
						</div>
						<div class="item-circle">{{ itemC.good_unit }}</div>
						<div class="item-txt">数量：<span class="txt-num">x{{ itemC.good_num - itemC.refund_num }}</span></div>
						<div class="item-txt txt-nomar">单价：<span class="txt-icon">¥</span>{{ itemC.base_price_arr.z_price }}<span class="txt-small">.{{ itemC.base_price_arr.x_price }}</span></div>
					</div>
				</div>
			</div>

            <!-- <div class="content-c" v-for="(item, index) in list" :key="index">
                <div class="conetnt-title">
                    <div class="title-flex">
                        <img class="title-img" src="https://files.onestep6.com/cloud/order-icon.png" />
                        <div class="title-txt">{{ item.user_shop_name }}</div>
                    </div>
                </div>
                <div class="content-order">
                    <div class="order-scroll">
                        <div class="scroll">
                            <div class="scroll-content">
                                <img class="scroll-img" v-for="(itemC, indexC) in item.goods" :key="indexC" :src="itemC.good_pics" />
                            </div>
                        </div>
                    </div>
                    <div class="order-num">
                        <span>共{{ item.goods.length }}件</span>
                        <img class="num-icon" src="https://files.onestep6.com/cloud/order-right.png" />
                    </div>
                </div>
                <div class="content-time">
                    <div class="time-txt">下单时间：<span class="txt-col">{{ item.created }}</span></div>
                    <div class="time-price">
                        <span>采购金额</span>
                        <span class="price-iocn">¥</span>
                        <span class="price-num">{{ item.shop_price_arr.z_price }}</span>
                        <span class="price-small">.{{ item.shop_price_arr.x_price }}</span>
                    </div>
                </div>
            </div> -->
        </div>

        <div class="price" v-if="info.status != 3">
			<div class="price-right">
            <a id="callBtn" :href="`tel:+86${phone}`">
                <van-button class="refund-btn">联系财务</van-button>
            </a>
			</div>
            <div v-if="info.status == 1" class="price-right">
				<van-button class="price-btn" @click="confirmOrder">确认订单</van-button>
			</div>
            <div v-if="info.status == 2" class="price-right">
				<van-button class="btn-txt">待打款</van-button>
			</div>
		</div>

        <popup-choose ref="popupChoose" txt="请仔细核对账单，账单无误后，点击确认，平台将会安排财务为你打款。" @right="onRight" />

    </div>
</template>
<script>
import { ImagePreview } from 'vant';
import popupChoose from "@/components/popupChoose.vue";
import { settlementInfo, setEndOrder } from "@/api/cloud";
export default {
    components: {
        popupChoose
    },
    data() {
        return {
            set_id: '',
            list: [],
            info: {},
            money_account: {},
            phone: ''
        }
    },
    mounted() {
        this.set_id = this.$route.query.id;
        this.settlementInfo()
    },
    methods: {
        async settlementInfo() {
            const res = await settlementInfo({
                id: this.set_id
            })
            if (res.status == 1) {
                this.info = res.data.info;
                this.list = res.data.list;
                this.money_account = res.data.money_account;
                this.phone = res.data.phone;
            }
        },
        onClickLeft() {
            this.$router.back();
        },
        seeImg(img) {
            ImagePreview([img]);
        },
        confirmOrder() {
            this.$refs.popupChoose.show()
        },
        // 确认订单
        async onRight() {
            const res = await setEndOrder({
                id_arr: [this.set_id]
            })
            if (res.status == 1) {
                this.info.status = 2;
            }
        },
        onDetail(item) {
			this.$router.push({
				path: '/goodDetail',
				query: {
					id: item.good_id
				}
			})
		}
    },
}
</script>
<style lang="less" scoped>
.pages {
    padding-top: calc(92px);
    padding-bottom: 198px;
    min-height: 100vh;
    background: #F6F6F6;

    ::v-deep .van-nav-bar .van-icon {
        color: #323233;
    }

    ::v-deep .van-nav-bar {
        background: #FFFFFF;
    }

    ::v-deep .van-hairline--bottom::after {
        border: none;
    }
}


.content {
    padding: 24px;

    .content-item {
        width: 702px;
        padding: 32px 22px 0px 36px;
        background: #FFFFFF;
        border-radius: 16px;
        margin-bottom: 20px;

        .item-title {
            font-size: 28px;
            line-height: 34px;
            color: #202630;
            font-weight: bold;
            border-bottom: 2px solid #F5F5F6;
            padding-bottom: 30px;
            margin-bottom: 32px;
        }

        .item-flex {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 20px;
        }
        .flex-start{
            align-items: flex-start;
        }

        .item-name {
            font-size: 24px;
            line-height: 30px;
            color: #798391;
            font-weight: bold;
        }

        .item-num {
            font-size: 24px;
            line-height: 30px;
            font-weight: bold;
            color: #202630;
        }

        .item-price {
            font-size: 24px;
            line-height: 30px;
            font-weight: bold;
            color: #FF4D4F;
        }
        .item-img{
            display: block;
            width: 128px;
            height: 128px;
            border-radius: 8px;
        }
    }
}

.content-c {
    width: 702px;
    border-radius: 16px;
    padding: 30px 26px 20px 32px;
    background: #FFFFFF;
    margin: 0 auto 24px;

    .conetnt-title {
        display: flex;
        justify-content: space-between;
        margin-bottom: 32px;

        .title-flex {
            display: flex;
            align-items: center;
        }

        .title-img {
            flex-shrink: 0;
            display: block;
            width: 36px;
            height: 36px;
            margin-right: 8px;
        }

        .title-txt {
            font-size: 32px;
            line-height: 36px;
            color: #141414;
            font-weight: bold;
        }
    }

    .content-order {
        display: flex;
        align-items: center;
        margin-bottom: 40px;

        .order-scroll {
            width: 502px;
            height: 128px;

            .scroll {
                width: 502px;
                height: 128px;
                overflow-x: scroll;
                scrollbar-width: none;
                /* Firefox 隐藏滚动条 */
                -ms-overflow-style: none;
                /* IE 10+ 隐藏滚动条 */
            }

            .scroll::-webkit-scrollbar {
                display: none;
                /* Chrome、Safari、Edge 隐藏滚动条 */
            }
        }

        .scroll-content {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;

            .scroll-img {
                flex-shrink: 0;
                display: block;
                width: 128px;
                height: 128px;
                border-radius: 8px;
                margin-right: 24px;
            }
        }

        .order-num {
            flex: 1;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            font-size: 24px;
            line-height: 24px;
            color: #798391;
            font-weight: 400;

            .num-icon {
                flex-shrink: 0;
                display: block;
                width: 24px;
                height: 24px;
                margin-left: 2px;
            }
        }
    }

    .content-time {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .time-txt {
            font-size: 20px;
            line-height: 22px;
            color: #798391;
            font-weight: 400;

            .txt-col {
                color: #49CA6F;
            }
        }
        .time-price {
            font-size: 24px;
            color: #141414;
            font-weight: bold;

            .price-iocn {
                margin-left: 4px;
                margin-right: 2px;
            }

            .price-num {
                font-size: 40px;
            }

            .price-small {
                font-size: 28px;
            }
        }
    }
}

.price{
	position: fixed;
    left: 0;
    bottom: 0;
	display: flex;
	justify-content: flex-end;
    width: 100vw;
    padding-top: 19px;
	padding-left: 56px;
	padding-right: 28px;
    padding-bottom: calc(20px + constant(safe-area-inset-bottom)); /* 兼容 iOS<11.2 */
    padding-bottom: calc(20px + env(safe-area-inset-bottom)); /* 兼容iOS>= 11.2 */
    background: #FFFFFF;
	.price-right{
		display: flex;
		align-items: center;
		.price-btn{
			flex-shrink: 0;
			display: block;
			width: 216px;
			height: 72px;
			background: #49CA6F;
			border-radius: 39px;
			font-size: 32px;
			line-height: 72px;
			color: #FFFFFF;
			font-weight: 500;
			border:none;
			margin-left: 14px;
		}
		.price-btn::after{
			border:none;
		}
        .btn-txt {
            width: 216px;
			height: 72px;
            background: #F5F5F6;
            border-radius: 39px;
            font-size: 32px;
            line-height: 72px;
            color: #798391;
            font-weight: 400;
            text-align: center;
            border: none;
            margin-left: 14px;
        }
        .btn-txt::before{
			border:none;
		}
		.refund-btn{
			width: 216px;
			height: 72px;
			border: 2px solid #49CA6F;
			font-size: 32px;
			line-height: 68px;
			color: #49CA6F;
			font-weight: 500;
			border-radius: 39px;
			background: #FFFFFF;
		}
	}
}

.delivery{
    width: 702px;
    padding-bottom: 36px;
	background: #FFFFFF;
	border-radius: 16px;
    margin: 0 auto 24px;
	.delivery-title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 646px;
		height: 98px;
		font-size: 32px;
		line-height: 32px;
		font-weight: bold;
		color: #141414;
		border-bottom: 2px solid #F5F5F6;
		margin:0 auto 24px;
        .title-right{
            font-size: 24px;
            line-height: 32px;
            color: #798391;
            font-weight: 400;
            .right-price{
                font-size: 32px;
                line-height: 32px;
                color: #49CA6F;
                font-weight: bold;
            }
        }
	}
	.title-txt{
		font-size: 24px;
		line-height: 24px;
		color: #798391;
		font-weight: 400;
	}
	.delivery-item{
		display: flex;
		padding-left: 26px;
		padding-right: 22px;
		margin-bottom: 16px;
		.item-img{
			flex-shrink: 0;
			display: block;
			width: 220px;
			height: 220px;
			border-radius: 8px;
			margin-right: 24px;
		}
		.item-right{
			flex: 1;
			flex-shrink: 0;
		}
		.item-flex{
			display: flex;
			justify-content: space-between;
			margin-bottom: 10px;
		}
		.item-des{
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			overflow: hidden;
			text-overflow: ellipsis;
			flex-shrink: 0;
			width: 282px;
			font-size: 28px;
			line-height: 40px;
			color: #333333;
			font-weight: 400;
		}
		.item-price{
			font-size: 40px;
			line-height: 40px;
			color: #141414;
			font-weight: bold;
			.price-icon{
				font-size: 24px;
			}
			.price-small{
				font-size: 28px;
			}
		}
		.item-circle{
			width: fit-content;
			padding: 0px 6px;
			margin-right: 6px;
			margin-bottom: 14px;
			font-size: 20px;
            line-height: 24px;
			color: #FFFFFF;
			background: #49CA6F;
			border-radius: 4px;
		}
		.item-txt{
			font-size: 24px;
			line-height: 34px;
			font-weight: 400;
			color: #798391;
			margin-bottom: 14px;
		}
		.txt-icon{
			font-size: 20px;
		}
		.txt-small{
			font-size: 20px;
		}
		.txt-num{
			color: #FF4D4F;
		}
		.txt-nomar{
			margin-bottom: 0;
		}
	}
	.delivery-more{
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 24px;
		line-height: 40px;
		font-weight: 400;
		color: #798391;
		padding-top: 20px;
		padding-bottom: 12px;
		.more-img{
			display: block;
			width: 32px;
			height: 32px;
		}
		.more-back{
			transform: rotate(180deg);
		}
	}
}
</style>